namespace SP.Parameter
{
    public class TextureParamter : IParameter
    {
        public enum AddressMode
        { Wrap
        , Clamp
        }

        public enum Filter
        { Point
        , Linear
        , Anisotropy
        }

        public TextureParamter(string name, string samplerName)
        {
            mName = name;
            mSamplerName = samplerName;
            mPath = "";
        }

        private string mName;
        public string Name
        {
            get { return mName; }
        }

        private string mDesc;
        public string Desc
        {
            get { return mDesc; }
        }

        public string Value
        {
            get { return mPath; }
            set { mPath = value; }
        }

        private bool mEditable = true;
        public bool Editable
        {
            get { return mEditable; }
            set { mEditable = value; }
        }

        private string mSamplerName;
        public string SamplerName
        {
            get { return mSamplerName; }
        }

        public int ForceSamplerId = -1;

        private string mPath;
        public string Path
        {
            get { return mPath; }
            set { mPath = value; }
        }

        public bool SRGBTexture = false;

        public string UserData;

        public TextureParamter SetDesc(string desc)
        {
            mDesc = desc;
            return this;
        }

        public TextureParamter SetEditable(bool val)
        {
            mEditable = val;
            return this;
        }

        public TextureParamter SetSRGBTexture(bool val)
        {
            SRGBTexture = val;
            return this;
        }

        public TextureParamter SetUserData(string val)
        {
            UserData = val;
            return this;
        }

        public TextureParamter SetForceSamplerId(int id)
        {
            ForceSamplerId = id;
            return this;
        }
    }

    public class Texture2dParamter : TextureParamter
    {
        public Texture2dParamter(string name, string samplerName)
            : base(name, samplerName)
        {
        }

        public AddressMode UAddressMode = AddressMode.Wrap;
        public AddressMode VAddressMode = AddressMode.Wrap;
        public Filter MinFilter = Filter.Linear;
        public Filter MagFilter = Filter.Linear;
        public Filter MipFilter = Filter.Linear;

        public Texture2dParamter SetAddressModes(AddressMode uAddr, AddressMode vAddr)
        {
            UAddressMode = uAddr;
            VAddressMode = vAddr;
            return this;
        }

        public Texture2dParamter SetFilters(Filter minFilter, Filter magFilter, Filter mipFilter)
        {
            MinFilter = minFilter;
            MagFilter = magFilter;
            MipFilter = mipFilter;
            return this;
        }
    }

    public class TextureCubeParamter : TextureParamter
    {
        public TextureCubeParamter(string name, string samplerName)
            : base(name, samplerName)
        {
        }

        public AddressMode UAddressMode = AddressMode.Clamp;
        public AddressMode VAddressMode = AddressMode.Clamp;
        public AddressMode WAddressMode = AddressMode.Clamp;
        public Filter MinFilter = Filter.Linear;
        public Filter MagFilter = Filter.Linear;
        public Filter MipFilter = Filter.Linear;

        public TextureCubeParamter SetAddressModes(AddressMode uAddr, AddressMode vAddr, AddressMode wAddr)
        {
            UAddressMode = uAddr;
            VAddressMode = vAddr;
            WAddressMode = wAddr;
            return this;
        }

        public TextureCubeParamter SetFilters(Filter minFilter, Filter magFilter, Filter mipFilter)
        {
            MinFilter = minFilter;
            MagFilter = magFilter;
            MipFilter = mipFilter;
            return this;
        }
    }
}